
#include "ui_getParams.h"
#include "getParams.h"


GetParams::GetParams(QWidget *parent): QDialog(parent), paramUi(new Ui::GetParams)
{

    paramUi->setupUi(this);

    masters = 0;
    maxpacket = 0;
    minpacket = 0;
    speed = 0;
}

void GetParams::on_buttonBox_accepted()
{
    emit paramsSaved(masters, maxpacket, minpacket, speed);
}

void GetParams::on_buttonBox_rejected()
{
    emit paramsNotSaved();
}


void GetParams::shown()
{
    //reset private data when shown
    masters = 0;
    maxpacket = 0;
    minpacket = 0;
    speed = 0;

   //reset sliders when shown
    paramUi->masterSlider->setValue(0);
    paramUi->maxSlider->setValue(0);
    paramUi->minSlider->setValue(0);
    paramUi->speedSlider->setValue(0);

    // disables master select on multi sim
    if(multiSimTrue)
    {
        paramUi->masterSlider->setDisabled(true);
    }
    else
    {
         paramUi->masterSlider->setDisabled(false);
    }

}


void GetParams::on_masterSlider_valueChanged()
{
     masters = paramUi->masterSlider->value();

    paramUi->lcdMasters->display( masters);

}


void GetParams::on_maxSlider_valueChanged()
{
    maxpacket = paramUi->maxSlider->value();
    paramUi->lcdMax->display(maxpacket);

    if(maxpacket < paramUi->minSlider->value())
    {
        paramUi->minSlider->setValue(maxpacket);
    }

}

void GetParams::on_minSlider_valueChanged()
{
    minpacket = paramUi->minSlider->value();
    paramUi->lcdMin->display(minpacket);

    if(minpacket > paramUi->maxSlider->value())
    {
        paramUi->maxSlider->setValue(minpacket);
    }

}

void GetParams::on_speedSlider_valueChanged()
{
    speed = paramUi->speedSlider->value();
    paramUi->lcdSpeed->display(speed);

}
